package leetcode.editor.cn.q1xx

class Q167 {

    fun twoSum(numbers: IntArray, target: Int): IntArray {
        var low = 0
        var high = numbers.lastIndex
        while (low < high) {
            val count = numbers[low] + numbers[high]
            if (count == target) {
                break
            } else if (count < target) {
                low++
            } else {
                high--
            }
        }
        return intArrayOf(low + 1, high + 1)
    }
}